import request from '@/utils/request'

const returnOrder = {
  getSalesReturnOrderListAPI: function (params) {
    params = params || {}
    params.returnOrderType = 0
    return request({
      url: '/eims/returnorder/list',
      method: 'post',
      data: params
    })
  },
  getPurchaseReturnOrderListAPI: function (params) {
    params = params || {}
    params.returnOrderType = 1
    return request({
      url: '/eims/returnorder/list',
      method: 'post',
      data: params
    })
  },
  getReturnOrderAPI: function (returnNo) {
    return request({
      url: `/eims/returnorder/info/${returnNo}`,
      method: 'get'
    })
  },
  saveReturnOrderInfoAPI: function (params) {
    return request({
      url: '/eims/returnorder/save',
      method: 'post',
      data: params
    })
  },
  updateReturnOrderInfoAPI: function (params) {
    return request({
      url: '/eims/returnorder/update/' + params.returnNo,
      method: 'put',
      data: params
    })
  },
  updateReturnOrderStatusAPI: function (returnNo, status, params) {
    return request({
      url: `/eims/returnorder/update/status/${returnNo}/${status}`,
      method: 'put',
      data: params || {}
    })
  },
  getReturnOrderDetailListAPI: function (returnNo, returnOrderType) {
    return request({
      url: `/eims/returnorder/get/detail/${returnOrderType}/${returnNo}`,
      method: 'get'
    })
  },
  updateReturnOrderDetailAPI: function (params) {
    return request({
      url: `/eims/returnorder/update/detail/${params.id}`,
      method: 'put',
      data: params
    })
  },
  saveReturnOrderDetailAPI: function (params) {
    return request({
      url: `/eims/returnorder/save/detail/${params.returnNo}`,
      method: 'post',
      data: params
    })
  },
  deleteReturnOrderDetailInfoAPI: function (id) {
    return request({
      url: `/eims/returnorder/delete/detail/${id}`,
      method: 'delete'
    })
  }
}

export default returnOrder
